function loadEngine(sub_name, cb) {
  if (tt.loadSubpackage) {
    _load(sub_name).then((result) => {
      if (!result) {
        loadEngine(sub_name);
      } else {
        cb();//此处为了执行FIRSTRENDER = false;语句
      }
    });
  } else {
    require(sub_name + '/game.js');
  }
}

function _load(sub_name) {
  return new Promise((resolve, reject) => {
    const t = new Date().getTime();

    const loadTask = tt.loadSubpackage({
      name: sub_name,
      success: function (res) {
        console.log("引擎子包加载完毕", new Date().getTime() - t, "ms");
        resolve(true);
      },
      fail: function (res) {
        console.log("引擎子包加载失败", new Date().getTime() - t, "ms");
        resolve(false);
      }
    });

    loadTask.onProgressUpdate(res => {

    });

  });
}

const _loadEngine = loadEngine;
export { _loadEngine as loadEngine };